package com.yxplearn.mybatisplus.controller;

import com.alibaba.fastjson.JSON;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.util.CharsetUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/login")
@Controller
public class LoginController {

    @RequestMapping(value = "/login", method = RequestMethod.POST)
    @ResponseBody
    public byte[] login(@RequestBody AccountJsonMsg accountJsonMsg) {
        AccountJsonResMsg resMsg = new AccountJsonResMsg();
        resMsg.setPlayerId(1329009287399804929L);
        resMsg.setIpAdd("10.1.11.225:1025");
        resMsg.setsId(7);
        HttpResponseMsg msg = new HttpResponseMsg(0, resMsg);
        ByteBuf byteBuf = Unpooled.copiedBuffer(msg.toJsonString(), CharsetUtil.UTF_8);
        return byteBuf.array();
    }
}
